#include "include.h"

using namespace std;

SDL_Surface *SDLEventsScreenGame = NULL;

bool isMouseDown;

void onEventsStart(SDL_Surface* ScreenGame)
{
	SDLEventsScreenGame = ScreenGame;
}

void onGameExits()
{
	onMainGameStopping();
	SDL_Quit();
}

void onGameEvents(SDL_Event& events)
{
	switch (events.type)
	{
	case SDL_QUIT:
		{
			onGameExits();
			break;
		}
	case SDL_MOUSEBUTTONUP:
		{
			isMouseDown = false;
			break;
		}
	case SDL_MOUSEBUTTONDOWN:
		{
			if (events.button.button == SDL_BUTTON_LEFT)
			{
				isMouseDown = true;
				break;
			}
		}
	case SDL_MOUSEMOTION:
		{
			if (isMouseDown)
			{
				
			}
			break;
		}
	case SDL_KEYDOWN:
		{
			if (events.key.state == SDL_PRESSED && events.key.keysym.sym == SDLK_PRINT)
			{
				string filename;
				time_t timei;
				struct tm * timeinfo;
				time (&timei);
				timeinfo = localtime ( &timei );
				filename = FOLDER_Screenshot;
				filename += "screenshot";
				filename += IntToString(timeinfo->tm_hour);
				filename += IntToString(timeinfo->tm_min);
				filename += IntToString(timeinfo->tm_sec);
				filename += IntToString(timeinfo->tm_mday);
				filename += IntToString(timeinfo->tm_mon+1);
				filename += IntToString(timeinfo->tm_year+1900);
				filename += ".bmp";
				SDL_SaveBMP(SDLEventsScreenGame, filename.c_str());
			}
		}
	}
}